package com.huahua.api.util;

import com.google.common.collect.Lists;
import org.dromara.hutool.core.math.NumberUtil;
import org.dromara.hutool.core.stream.StreamUtil;
import org.dromara.hutool.core.text.StrUtil;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author LoveHuaHua
 * @date 2024年09月05日 14:47
 * @description believe in yourself
 */
public class StrListUtil {
    public static String joinInteger(List<Integer> list) {
        return StreamUtil.of(list).map(String::valueOf).collect(Collectors.joining(","));
    }

    public static String join(Collection<String> list) {
        return String.join(",", list);
    }

    public static List<String> split(String str) {
        return split(str, ",");
    }

    public static List<String> split(String str, String spit) {
        if (StrUtil.isEmpty(str)) {
            return Lists.newArrayList();
        }
        return Lists.newArrayList(str.split(spit));
    }

    public static List<Integer> splitInteger(String str) {
        return StreamUtil.of(split(str)).map(NumberUtil::parseInt).collect(Collectors.toList());
    }


}
